package com.example.eschool.fragment;

import android.os.Bundle;

import androidx.fragment.app.Fragment;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ListView;

import com.example.eschool.MessageAdapter;
import com.example.eschool.R;
import com.example.eschool.bean.Message;

import java.util.ArrayList;
import java.util.List;

/**
 * A simple {@link Fragment} subclass.
 * Use the {@link MessageFragment#newInstance} factory method to
 * create an instance of this fragment.
 */
public class MessageFragment extends Fragment {
    private ListView listView;
    private MessageAdapter messageAdapter;
    private List<Message> messageList;
    public MessageFragment() {
        // Required empty public constructor
    }
    public static MessageFragment newInstance(String param1, String param2) {
        MessageFragment fragment = new MessageFragment();
        Bundle args = new Bundle();

        fragment.setArguments(args);
        return fragment;
    }
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.fragment_message, container, false);
        listView = view.findViewById(R.id.messageList);
        messageList=new ArrayList<>();
        messageList.add(new Message("[支付中心]一卡通充值","￥200元","系统通知","2024-5-13","农行支付，支付成功"));
        messageList.add(new Message("[支付中心]一卡通充值","￥200元","系统通知","2024-5-13","农行支付，支付成功"));
        messageList.add(new Message("[支付中心]一卡通充值","￥200元","系统通知","2024-5-13","农行支付，支付成功"));
        messageList.add(new Message("[支付中心]一卡通充值","￥200元","系统通知","2024-5-13","农行支付，支付成功"));
        messageList.add(new Message("[支付中心]一卡通充值","￥200元","系统通知","2024-5-13","农行支付，支付成功"));
        messageList.add(new Message("[支付中心]一卡通充值","￥200元","系统通知","2024-5-13","农行支付，支付成功"));
        messageList.add(new Message("[支付中心]一卡通充值","￥200元","系统通知","2024-5-13","农行支付，支付成功"));
        messageList.add(new Message("[支付中心]一卡通充值","￥200元","系统通知","2024-5-13","农行支付，支付成功"));
        messageList.add(new Message("[支付中心]一卡通充值","￥200元","系统通知","2024-5-13","农行支付，支付成功"));
        messageList.add(new Message("[支付中心]一卡通充值","￥200元","系统通知","2024-5-13","农行支付，支付成功"));
        messageList.add(new Message("[支付中心]一卡通充值","￥200元","系统通知","2024-5-13","农行支付，支付成功"));
        messageList.add(new Message("[支付中心]一卡通充值","￥200元","系统通知","2024-5-13","农行支付，支付成功"));

        messageAdapter=new MessageAdapter(getActivity(),messageList);
        listView.setAdapter(messageAdapter);

        return view;
    }
}